<!--
@ 作者: 阿拉丁矿工 黄传鸿 <hchhyzc@foxmail.com>
-->
<template>
  <div class="right_pen">
    <div class="right_pen_top">
      <!---------------------------|预览 -->
      <div class="h_flex_column_center">
        <text>画笔预览</text>
        <div class="h_flex_row_between">
          <svg
            width="100px"
            height="100px"
            version="1.1"
            xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
          >
            <g transform="scale(0.1)">
              <line
                :stroke="Store.selectedPen.stroke"
                :stroke-width="Store.selectedPen.stroke_width"
                :stroke-dasharray="Store.selectedPen.stroke_dasharray"
                :stroke-dashoffset="Store.selectedPen.stroke_dashoffset"
                :stroke-linecap="Store.selectedPen.stroke_linecap"
                :opacity="Store.selectedPen.opacity"
                x1="100"
                y1="500"
                x2="900"
                y2="500"
              ></line>
            </g>
          </svg>
          <svg
            width="100px"
            height="100px"
            version="1.1"
            xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
          >
            <g transform="scale(0.1)">
              <circle
                :stroke="Store.selectedPen.stroke"
                :stroke-width="Store.selectedPen.stroke_width"
                :stroke-dasharray="Store.selectedPen.stroke_dasharray"
                :stroke-dashoffset="Store.selectedPen.stroke_dashoffset"
                :stroke-linecap="Store.selectedPen.stroke_linecap"
                :fill="Store.selectedPen.fill"
                :opacity="Store.selectedPen.opacity"
                :fill-opacity="Store.selectedPen.fill_opacity"
                :stroke-opacity="Store.selectedPen.stroke_opacity"
                cx="500"
                cy="500"
                r="400"
              ></circle>
            </g>
          </svg>
        </div>
      </div>
    </div>

    <div class="right_pen_down">
      <!---------------------------|名称 -->
      <!-- 画笔名称 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">画笔名称</text>
        <NInput
          class="h_info_val"
          type="text"
          v-model:value="Store.selectedPen.label"
          placeholder="未选择，请选择画笔"
        />
      </div>

      <!-- 轮廓宽度 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">轮廓宽度</text>
        <div class="h_flex_column h_info_val">
          <NSlider
            class="h_margin_top_10"
            :min="0"
            :step="0.01"
            v-model:value="Store.selectedPen.stroke_width"
          />
          <NInputNumber
            class="h_margin_top_10"
            :min="0"
            :step="0.01"
            v-model:value="Store.selectedPen.stroke_width"
            placeholder="边框宽度"
          />
        </div>
      </div>
      <!---------------------------|线样式 -->
      <!-- 虚线 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">虚线</text>
        <NInput
          class="h_info_val"
          type="text"
          v-model:value="Store.selectedPen.stroke_dasharray"
          placeholder="未定义"
        />
      </div>
      <!-- 线虚实偏移 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">线虚实偏移</text>
        <div class="h_flex_column h_info_val">
          <NSlider
            class="h_margin_top_10"
            :min="-10000"
            :max="10000"
            :step="1"
            v-model:value="Store.selectedPen.stroke_dashoffset"
          />
          <NInputNumber
            class="h_margin_top_10"
            :min="-10000"
            :max="10000"
            :step="1"
            v-model:value="Store.selectedPen.stroke_dashoffset"
            placeholder="线虚实偏移"
          />
        </div>
      </div>
      <!-- 端点样式 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">端点样式</text>
        <NSelect
          class="h_info_val"
          v-model:value="Store.selectedPen.stroke_linecap"
          :options="lineCapOpt"
        />
      </div>

      <!---------------------------|颜色 -->
      <!-- 轮廓颜色 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">轮廓颜色</text>
        <NColorPicker
          class="h_info_val"
          v-model:value="Store.selectedPen.stroke"
          :actions="['confirm']"
          :modes="['rgb']"
          :swatches="colorOpt"
          :show-alpha="true"
        />
      </div>
      <!-- 填充颜色 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">填充颜色</text>
        <NColorPicker
          class="h_info_val"
          v-model:value="Store.selectedPen.fill"
          :actions="['confirm']"
          :modes="['rgb']"
          :swatches="colorOpt"
          :show-alpha="true"
        />
      </div>

      <!---------------------------|透明度 -->
      <!-- 透明度 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">透明度</text>
        <div class="h_flex_column h_info_val">
          <NSlider
            class="h_margin_top_10"
            :min="0"
            :step="0.01"
            :max="1"
            v-model:value="Store.selectedPen.opacity"
          />
          <NInputNumber
            class="h_margin_top_10"
            :min="0"
            :step="0.01"
            :max="1"
            v-model:value="Store.selectedPen.opacity"
            placeholder="边框宽度"
          />
        </div>
      </div>
      <!-- 填充透明度 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">填充透明度</text>
        <div class="h_flex_column h_info_val">
          <NSlider
            class="h_margin_top_10"
            :min="0"
            :step="0.01"
            :max="1"
            v-model:value="Store.selectedPen.fill_opacity"
          />
          <NInputNumber
            class="h_margin_top_10"
            :min="0"
            :step="0.01"
            :max="1"
            v-model:value="Store.selectedPen.fill_opacity"
            placeholder="边框宽度"
          />
        </div>
      </div>
      <!-- 轮廓透明度 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">轮廓透明度</text>
        <div class="h_flex_column h_info_val">
          <NSlider
            class="h_margin_top_10"
            :min="0"
            :step="0.01"
            :max="1"
            v-model:value="Store.selectedPen.stroke_opacity"
          />
          <NInputNumber
            class="h_margin_top_10"
            :min="0"
            :step="0.01"
            :max="1"
            v-model:value="Store.selectedPen.stroke_opacity"
            placeholder="边框宽度"
          />
        </div>
      </div>

      <!---------------------------|圆角 -->
      <!-- 左边圆角 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">左边圆角</text>
        <div class="h_flex_column h_info_val">
          <NSlider
            class="h_margin_top_10"
            :min="0"
            :max="10000"
            :step="1"
            v-model:value="Store.selectedPen.fx"
          />
          <NInputNumber
            class="h_margin_top_10"
            :min="0"
            :max="10000"
            :step="1"
            v-model:value="Store.selectedPen.fx"
          />
        </div>
      </div>
      <!-- 右边圆角 -->
      <div class="h_info" v-if="Store.penSelectState === 2">
        <text class="h_info_lable">右边圆角</text>
        <div class="h_flex_column h_info_val">
          <NSlider
            class="h_margin_top_10"
            :min="0"
            :max="10000"
            :step="1"
            v-model:value="Store.selectedPen.fy"
          />
          <NInputNumber
            class="h_margin_top_10"
            :min="0"
            :max="10000"
            :step="1"
            v-model:value="Store.selectedPen.fy"
          />
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
/* ================================================================================================ */
// 🍀引入
/* ================================================================================================ */
import { reactive, ref, toRefs, computed, watch, nextTick, onMounted } from "vue";

/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// 🐸 图元端函数引入
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
import {} from "@/functions";

/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// 🐸 引入存储
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
import { useCanvasStore } from "@/store/canvasStore"; // 画布
import { useStaticStore } from "@/store/staticStore"; // 静态

/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
// 🐸 使用存储
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
const canvasStore = useCanvasStore(); // 画布
const staticStore = useStaticStore(); // 静态

/* ================================================================================================ */
//                                 ★变量
/* ================================================================================================ */
/** 存储 */
let Store = reactive({
  /** 笔筒 */
  penContainer: computed(() => canvasStore.penContainer),
  /** 选中的笔桶 */
  selectedPenContainer: computed(() => canvasStore.selectedPenContainer),
  /** 笔选择状态-0无-1笔筒-2笔-3已下载-4上载 */
  penSelectState: computed(() => canvasStore.penSelectState),
  /** 选中的笔 */
  selectedPen: computed(() => canvasStore.selectedPen),
});
// ——————————————————————————————————————————————————————————————————————————| 选项
/** 线端点选项 */
let lineCapOpt = staticStore.lineCapOpt;
/** 颜色选项卡 */
let colorOpt = staticStore.colorOpt;

</script>

<style lang="scss" scoped>
/* 引入共用css */
@import "@/assets/h.scss";
.right_pen {
  width: 100%;
  height: 100%;
  user-select: none;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  overflow: hidden;
}

.right_pen_down {
  height: 80vh;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  background-color: rgb(80,80,80);
  text-align: center;
  font-size: medium;
  color: #ffffff;
  overflow-x: hidden;
  overflow-y: scroll;

  /* firefox */
  scrollbar-color: rgba(144, 146, 152, 0.3) transparent;
  scrollbar-width: auto;

  /* chrome */
  &::-webkit-scrollbar,
  &::-webkit-scrollbar-track-piece {
    background-color: transparent;
  }

  &::-webkit-scrollbar {
    width: 10px;
    height: 10px;
  }

  &::-webkit-scrollbar-thumb {
    border-radius: 5px;
    background-color: rgb(197, 197, 197);
  }
}

/* 参数 */
.h_info {
  padding: 5px;
  width: 100%;
  user-select: none;
  display: flex;
  flex-direction: row;
  justify-content: start;
  align-items: center;
}

/* 参数标题 */
.h_info_lable {
  padding-left: 3px;
  width: 150px;
}

/* 参数变量 */
.h_info_val {
  width: 100%;
  margin-right: 16px;
}
</style>
